/*

Load an image using cv::imread
Transform an image from BGR to Grayscale format by using cv::cvtColor
Save your transformed image in a file on disk (using cv::imwrite )

http://docs.opencv.org/trunk/db/d64/tutorial_load_save_image.html
Data:2017.04.24

*/

#include <opencv2/opencv.hpp>
using namespace cv;
int main( int argc, char** argv )
{
    String imageName("../data/image.jpg");
    if( argc > 1)
    {
        imageName = argv[1];
    }

    Mat image;
    image = imread( imageName);
    if( image.empty() )
    {
        printf( " No image data \n " );
        return -1;
    }
    Mat gray_image;
    cvtColor( image, gray_image, COLOR_BGR2GRAY );
    imwrite( "../data/gray_image.jpg", gray_image );

    Mat gray_image2;
    cvtColor( image, gray_image2, COLOR_RGB2GRAY );
    imwrite( "../data/gray_image2.jpg", gray_image );

//    namedWindow( imageName, WINDOW_AUTOSIZE );
//    namedWindow( "Gray image", WINDOW_AUTOSIZE );
//    imshow( imageName, image );
//    imshow( "Gray image", gray_image );
//    waitKey(0);

    return 0;
}
